package com.fwmagic.dp._5;

import java.util.ArrayList;

public class Director {

    private ArrayList<String> sequence = new ArrayList<>();
    private BenzCarBuilder benzCarBuilder = new BenzCarBuilder();
    private BWMCarBuilder bwmCarBuilder = new BWMCarBuilder();

    /**
     * A类型的奔驰车模型，先start，然后stop，其他什么引擎、喇叭一概没有
     * @return
     */
    public BenzModel getABenzModel(){
        //清理场景，防止数据错乱
        this.sequence.clear();
        this.sequence.add("start");
        this.sequence.add("stop");
        //按顺序返回一个奔驰车
        this.benzCarBuilder.setSequence(sequence);
        return (BenzModel)this.benzCarBuilder.getCarModel();
    }

    /**
     * B型号的奔驰车模型，是先发动引擎，然后启动，然后停止，没有喇叭
     * @return
     */
    public BenzModel getBBenzModel(){
        //清理场景，防止数据错乱
        this.sequence.clear();
        this.sequence.add("engineBoom");
        this.sequence.add("start");
        this.sequence.add("stop");
        //按顺序返回一个奔驰车
        this.benzCarBuilder.setSequence(sequence);
        return (BenzModel)this.benzCarBuilder.getCarModel();
    }

    /**
     * C型号的宝马车是先按下喇叭，然后启动，然后停止
     * @return
     */
    public BWMModel getCBwmModel(){
        //清理场景，防止数据错乱
        this.sequence.clear();
        this.sequence.add("alarm");
        this.sequence.add("start");
        this.sequence.add("stop");
        //按顺序返回一个宝马
        this.bwmCarBuilder.setSequence(sequence);
        return (BWMModel)this.bwmCarBuilder.getCarModel();
    }

    /**
     * D类型的宝马车只有一个功能，就是跑，启动起来就跑，永远不停止
     * @return
     */
    public BWMModel getDBwmModel(){
        //清理场景，防止数据错乱
        this.sequence.clear();
        this.sequence.add("start");
        //按顺序返回一个宝马
        this.bwmCarBuilder.setSequence(sequence);
        return (BWMModel)this.bwmCarBuilder.getCarModel();
    }

    /**
     * ……
     */

}
